package nz.ac.massey.doi_information_extractor.tests;
import static org.junit.Assert.assertTrue;
import nz.ac.massey.doi_information_extractor.data.Author;
import nz.ac.massey.doi_information_extractor.data.AuthorList;
import nz.ac.massey.doi_information_extractor.data.Publication;
import nz.ac.massey.doi_information_extractor.gui.AbstractGui;
import nz.ac.massey.doi_information_extractor.gui.Gui;

import org.junit.*;

public class GuiTest {

	AbstractGui userInterface;
	Publication publication;

	@Before
	public void setUp(){
		userInterface = new Gui(null);
		AuthorList authorList = new AuthorList();
		authorList.add(new Author(1, "Fname1", "Lname1", "organisation1", "department1", "Authortype1", "userId1"));
		authorList.add(new Author(2, "Fname2", "Lname2", "organisation2", "department2", "Authortype2", "userId2"));
		authorList.add(new Author(3, "Fname3", "Lname3", "organisation3", "department3", "Authortype3",  "userId3"));

		publication = new Publication();
		publication.setArticleTitle("ArticleTitle 1");
		publication.setAuthors(authorList);
		publication.setConfidential(true);
		publication.setDate("date1");
		publication.setDescription("description1 eargraergeargaergaergeargeargaergeargeargaergeargaergeargeargeagaergaergaergaergaergaergaergaergaergaergaergaergaerg");
		publication.setDoi("doi1");
		publication.setIssn("issn1");
		publication.setPageNumbers("pagenumber1");
		publication.setPublicationId(1);
		publication.setPublicationTitle("title1");
		publication.setPublicationType("Journal");
		publication.setPublisher("publisher1");
		publication.setQualityAssured(true);
		publication.setResearchOrProfCom(true);
		publication.setUrl("url1");
		publication.setVolumeNumber("1");
		publication.setKeywords("Keywords1");
		publication.setConferenceDates("conferenceDates1");
		publication.setConferenceLocation("conferenceLocation1");
		publication.setPublisherLocation("publisherLocation1");
		publication.setEditors("editors1");
		publication.setJournalNumber("journalNumber1");
		publication.setEdition("edition1");
	}

	@After
	public void tearDown(){
		userInterface.setVisible(false);
		userInterface.dispose();
		userInterface = null;
	}

	@Test
	public void test1(){
		userInterface.setPublication(publication);
		Publication result = userInterface.getPublication();

		assertTrue(result.getArticleTitle().equals(publication.getArticleTitle()));
		assertTrue(result.getConferenceDates().equals(publication.getConferenceDates()));
		assertTrue(result.getConferenceLocation().equals(publication.getConferenceLocation()));
		assertTrue(result.getConfidential() == publication.getConfidential());
		assertTrue(result.getDate().equals(publication.getDate()));
		assertTrue(result.getDescription().equals(publication.getDescription()));
		assertTrue(result.getDoi().equals(publication.getDoi()));
		assertTrue(result.getEditors().equals(publication.getEditors()));
		assertTrue(result.getIssn().equals(publication.getIssn()));
		assertTrue(result.getEdition().equals(publication.getEdition()));
		assertTrue(result.getKeywords().equals(publication.getKeywords()));
		assertTrue(result.getPageNumbers().equals(publication.getPageNumbers()));
		assertTrue(result.getPublicationId() == publication.getPublicationId());
		assertTrue(result.getPublicationTitle().equals(publication.getPublicationTitle()));
		assertTrue(result.getPublicationType().equals(publication.getPublicationType()));
		assertTrue(result.getPublisher().equals(publication.getPublisher()));
		assertTrue(result.getPublisherLocation().equals(publication.getPublisherLocation()));
		assertTrue(result.getQualityAssured() == publication.getQualityAssured());
		assertTrue(result.getResearchOrProfCom() == publication.getResearchOrProfCom());
		assertTrue(result.getUrl().equals(publication.getUrl()));
		assertTrue(result.getVolumeNumber().equals(publication.getVolumeNumber()));
		assertTrue(result.getPublisher().equals(publication.getPublisher()));
	}
}
